import {ObjectID} from "mongodb";
import {Promise} from 'es6-promise';

import {
    SexType, AuthType, RegLoginType, UserStatus, ExpressAddStatus,
    UserRegType, PPEDepartType, SysUserStatus, PayType,
    ShipType, TransType, TransStatus
} from "./defines";
import {
    FindParam, FindOneParam, FindOneUpdateParam, FindOneDeleteParam,
    FindOneReplaceParam, InsertParam, UpdateParam, DeleteParam, CountParam,
    GroupParam, DistinctParam, MapReduceParam, AggregateParam
} from "./params";

export interface IUnknown { toString(): string; }

export interface IParam extends IUnknown { isValid(): boolean; }

export interface Address { name: string, id?: number }

export interface Owner { id: ObjectID | string, name: string }

export interface Location { prov: string, city: string, dist: string}

export interface IModel extends IUnknown {
    find(param: FindParam): Promise<any>;
    findOne(param: FindOneParam): Promise<any>;
    findOneAndUpdate(param: FindOneUpdateParam): Promise<any>;
    findOneAndDelete(param: FindOneDeleteParam): Promise<any>;
    findOneAndReplace(param: FindOneReplaceParam): Promise<any>;

    insertOne(param: InsertParam<Object>): Promise<any>;
    insertMany(param: InsertParam<[Object]>): Promise<any>;

    updateOne(param: UpdateParam): Promise<any>;
    updateMany(param: UpdateParam): Promise<any>;

    deleteOne(param: DeleteParam): Promise<any>;
    deleteMany(param: DeleteParam): Promise<any>;

    count(param: CountParam): Promise<any>;
    group(param: GroupParam): Promise<any>;
    distinct(param: DistinctParam): Promise<any>;
    mapReduce(param: MapReduceParam): Promise<any>;
    aggregate(param: AggregateParam): Promise<any>;
}

export interface AuditLog {
    from?: number,
    to?: number,
    log?: string,
    staff?: string,
    time: Date
}

export interface ModList {
    records: Array<Object>,
    curr_page?: number,
    total_count?: number,
    total_page?: number,
    limit?: number,
}